/*
 *  POJ1573: Robot Motion
 */

/*-------- Includes --------*/
#include <iostream>

using namespace std;

/*-------- Main Function --------*/
int main(int argc, char const *argv[])
{
    int row, col, entry;

    while (cin >> row >> col >> entry && row) {
        char *map[row];

        for (int i = 0; i < row; i++) {
            map[i] = new char[col + 1];
            cin >> map[i];
        }

        int x = 0;
        int y = entry - 1;
        int k = 0;

        while (true) {
            // exit
            if (x == -1 ||  x == row || y == -1 || y == col) {
                cout << k << " step(s) to exit" << endl;
                break;
            }

            // loop
            if (map[x][y] < 0x40) {
                cout << (int)map[x][y] << " step(s) before a loop of " << k - map[x][y] << " step(s)" << endl;
                break;
            }

            // go next
            char c = map[x][y];

            map[x][y] = k++;

            switch (c) {
                case 'E': y++; break;
                case 'S': x++; break;
                case 'W': y--; break;
                case 'N': x--; break;
                default :      break;
            }
        }

        // release resources
        for (int i = 0; i < row; i++)
            delete [] map[i];
    }

    return 0;
}
